using BootBlazor.Im.Backgrounds;
using BootBlazor.Im.Core;
using BootBlazor.Im.Events;
using BootBlazor.Servers.Helper;
using BootBlazor.Servers.Modules;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace BootBlazor.Im;

public class ImModule : IModule
{
    public IServiceCollection Add(IServiceCollection services)
    {
        services.AddHostedService<SendMessageBackgroundService>();
        services.AddScoped<EventHelper<UpdateNoReadCountEvent>>();

        return services;
    }

    public WebApplication Use(WebApplication app)
    {
        app.MapHub<ChatHub>(ChatHub.ChatHubUrl);
        return app;
    }
}
